Repository navigation
Visualizer: a display of literals has no steps (P40) - #48
Merged
Merged
Conversation
A list, tuple, set or dict display records no step of its own once its parts are values; a negative number literal records none either. Only unpacking and a set or dict losing duplicates keep the display's step. Unpacking in a display now gives Python's value ([*a, 2] was [[1], 2]). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cedricvogel-leo
force-pushed
the
feature/literal-displays
branch
from
November 4, 2026 23:39
ddba69c to
3e746a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A list, tuple, set or dict display no longer has a step of its own: once its parts are values, it reads as its value, as on paper. This applies in Ersetzung and Kasten, since both show the same trace.
A display of literals has no steps, nested at any depth:
baum = ["+", ["*", 2, ["-", 7, 3]], ["/", ["+", 1, 2], 3]]has one step, the assignment.Negative number literals (
-3,-2.5,-1j: unary minus applied to a number literal) have no step, inside a display or anywhere else.["-", 7, -3]and[-1, 2]have no steps.Names, calls and operators keep their steps, and the step that only built the display is gone:
[1 + 2, 3, 4] → [3, 3, 4][a, 2] → [5, 2][[1, 2], x] → [[1, 2], 7]["+", 1, ["*", n, 3]] → ["+", 1, ["*", 2, 3]]Each is one step.
The display keeps its step only where its value reads differently from what is written:
[*b, 2] → [1, 2],{**d, "j": 2};{1, 1} → {1}.These are the only cases where the «build» step changes something.
Unchanged:
dauer[1] → 2;notenschnitt(noten) → notenschnitt([5, 4.5, 6]);IndexErrorstep fordauer[3].[1, 2, 30][1] → 2is now a single step: the literal's step[1, 2, 30] → [1, 2, 30]changed nothing. The P39 check now expects that.Fixed along the way (please confirm): unpacking in a display gave the wrong value.
[*b, 2]withb = [1]gave[[1], 2]; Python gives[1, 2]. The same happened for tuples and sets. I fixed it because the handlers being rewritten here contained the bug, and without the build step the wrong value would have reached the variables panel unseen. A check compares the result with Python.Checks
scripts/check-runtime-lists.py:baumliteral,["-", 7, -3],[-1, 2], a mixed tuple/dict/set of literals and-3have no steps except the assignment, and their values are Python's.(n, -n, {n: [n]})and[len([1, 2]), 3].[1, 2, 30][1], which is now one step.scripts/check-console-browser.mjssteps through a program with these displays in both Kasten and Ersetzung. Every step must change the code or the variables, and the program has exactly 10 steps (7 assignments, 3 substitutions).lint,test:runtime,test:protocolandtest:consolepass.How it goes live
maindeploys the embed, so the courses get it straight away.v0.1.24on the merge commit, and I'll open the IDE bump PR.If P37 (#49) is merged too, one tag covers both.
Manual tests (desktop, and iPad with an external keyboard)
baum = ["+", ["*", 2, ["-", 7, 3]], ["/", ["+", 1, 2], 3]]in Ersetzung, then in Kasten. There is 1 step, andbaumappears in the variables.q = ["-", 7, -3]andr = [-1, 2]. There is one step per line.dauer = [1, 2, 30],x = dauer[1]goesdauer[1] → 2;[1, 2, 30][1]is one step to2;dauer[3]ends at the IndexError step;notenschnitt(noten)→notenschnitt([5, 4.5, 6]).Follow-ups (not fixed)
-xwithx = 7still has a step that changes nothing. Afterx → 7the line reads-7, and the step-7 → -7follows. I left it out because skipping it whenever the text matches would leave-(a + b)showing-(3). To decide: drop the unary-minus step when its operand is a name.+3(unary plus) keeps its step+3 → 3, which does change the text. Say if it should count as a literal too.test:consolefailed in theinput()check from P36, which this PR doesn't touch, and passed on a rerun. The console's text included the entry's «Visualisieren» button label before the input lines (">>> repl()\nVisualisieren\n> 1 + 2…"). That check is timing-dependent; it should read the transcript without the buttons.🤖 Generated with Claude Code